//NvPowerItem.qml
import QtQuick 2.15
import org.ukui.nvpower 1.0

Rectangle {
    implicitWidth: 125
    implicitHeight: 40
    radius: 6
    color: Qt.rgba(255, 255, 255, 0.5)
    border.color: "black"

    NvPower {
        id: nvPower
    }

    Text {
        id: text
        anchors.centerIn: parent
        text: "GPU功耗：" + nvPower.getGpuPowerUsage
        font.pointSize: 8
    }

    Component.onCompleted: {
        nvPower.utilChanged.connect(() => {
            text.text = "GPU功耗：" + nvPower.getGpuPowerUsage
        })
    }
    Component.onDestruction: {
        nvPower.utilChanged.disconnect()
    }

}